﻿using System;
using System.Collections.Generic;

namespace FinalPointSet.Model.Asset
{
    public static class ObjectAssetLoader
    {
        public static T Generate<T>(string path, Func<string, T> genearte)
        {
            return genearte.Invoke(path);
        }

        public static List<ObjectPair<T>> Generates<T>(string dir, Func<string, ObjectPair<T>> genearte)
        {
            string[]? filePath = AssetUtil.GetFilesPath(dir);
            List<ObjectPair<T>> pairs = new();
            if (filePath == null)
            {
                return new List<ObjectPair<T>>();
            }
            foreach (string path in filePath)
            {
                ObjectPair<T> fileValue = genearte(path);
                pairs.Add(fileValue);
            }
            return pairs;
        }
    }
}
